package com.iwhalecloud.citybrain.flow.platform.manager.domain.model;

import com.iwhalecloud.citybrain.flow.platform.manager.domain.repository.FlowNextNodeCandidateRepository;
import lombok.Data;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * @Description 下一节点流程候选人十二猴子领域模型
 * @author liujinjian
 * @date 2021-10-22
 * @version 1.0
 */
@Data
@Service
public class ModelNextNodeCandidateSettingsDomain implements Serializable, ApplicationContextAware {

    private static final long serialVersionUID = -8993347704509461610L;

    static FlowNextNodeCandidateRepository flowNextNodeCandidateRepository;

    /**
     * 主键ID
     */
    private Long id;

    /**
     * 父执行id
     */
    private String parentExecutionId;

    /**
     * 流程实例编码
     */
    private String processInstanceId;

    /**
     * 节点编码
     */
    private String nodeCode;

    /**
     * 数据类型：SAN，ORG，ROL
     */
    private String dataType;

    /**
     * 编码
     */
    private String code;

    /**
     * 名称
     */
    private String name;

    /**
     * 来源节点编码
     */
    private String fromNodeCode;

    /**
     * 任务ID
     */
    private String taskId;

    public void save() {
        flowNextNodeCandidateRepository.save(this);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        flowNextNodeCandidateRepository = applicationContext.getBean(FlowNextNodeCandidateRepository.class);
    }
}